Skip to content

Comments

feat: replication for p4 server#715

Draft
novekm wants to merge 1 commit intomainfrom
novekm/perforce-replica-support
Draft

feat: replication for p4 server#715
novekm wants to merge 1 commit intomainfrom
novekm/perforce-replica-support

Conversation

@novekm
Copy link
Contributor

@novekm novekm commented Aug 28, 2025

🚧 DRAFT PR - DO NOT MERGE UNTIL DRAFT STATUS HAS BEEN REMOVED AS WELL AS THIS LINE 🚧
Issue number:
#713

Summary

This PR implements P4 Server Replica Support for the Perforce module, enabling multi-AZ high availability and load distribution. Users can now deploy multiple P4 server replicas (standby, readonly, forwarding, edge) across different availability zones with automated configuration, DNS management, and comprehensive validation.

Changes

Key Changes:

  • Enhanced Variable Structure: Added p4_server_replicas_config variable supporting multiple replica types (standby, readonly, forwarding, edge)
  • Replica Infrastructure: Reuses existing p4-server submodule with inheritance from primary server configuration
  • Automated Configuration: S3 bucket for configuration scripts with SSM associations for automated replica setup
  • DNS Management: Route53 records for replica subdomains with automatic FQDN generation
  • IAM Permissions: Cross-region ready IAM policies with S3 access for script distribution
  • Validation Rules: Comprehensive validation ensuring replica compatibility with primary server
  • Dynamic Outputs: Complete replica information including connection strings, instance IDs, and FQDNs

Files Modified:

  • variables.tf - Added replica configuration variable with validation
  • main.tf - Added replica module calls with inheritance logic
  • s3.tf - S3 bucket and script uploads for replica configuration
  • ssm.tf - SSM associations for automated script execution
  • route53.tf - DNS records for replica subdomains
  • outputs.tf - Dynamic outputs for all replica information
  • modules/p4-server/iam.tf - Enhanced IAM policies for S3 access
  • examples/replica-single-region/ - Complete working example
  • examples/replica-cross-region/ - Cross-region example

User experience

Before:

module "perforce" {
  source = "../../modules/perforce"
  
  vpc_id = aws_vpc.main.id
  p4_server_config = {
    fully_qualified_domain_name = "perforce.yourdomain.com"
    instance_subnet_id = aws_subnet.private[0].id
  }
}
  • Single P4 server in one AZ
  • Single point of failure
  • No load distribution
  • Manual disaster recovery

After:

module "perforce" {
  source = "../../modules/perforce"
  
  vpc_id = aws_vpc.main.id
  p4_server_config = {
    fully_qualified_domain_name = "perforce.yourdomain.com"
    instance_subnet_id = aws_subnet.us_east_1a_private.id
  }
  
  p4_server_replicas_config = {
    "standby-1b" = {
      replica_type       = "standby"
      subdomain         = "standby"
      vpc_id            = aws_vpc.main.id
      instance_subnet_id = aws_subnet.us_east_1b_private.id
    }
    "readonly-1c" = {
      replica_type       = "readonly"
      subdomain         = "ci"
      vpc_id            = aws_vpc.main.id
      instance_subnet_id = aws_subnet.us_east_1c_private.id
    }
  }
}

Results:

  • High Availability: Multi-AZ deployment survives AZ failures
  • Load Distribution: Read operations distributed across replicas
  • Automatic DNS: standby.perforce.yourdomain.com, ci.perforce.yourdomain.com
  • Inheritance: Replicas automatically inherit primary server configuration
  • Validation: Ensures replica compatibility (storage, unicode, case sensitivity)
  • Automated Setup: SSM scripts configure replication automatically

Connection Strings Available:

Primary: ssl:perforce.yourdomain.com:1666
Standby: ssl:standby.perforce.yourdomain.com:1666
CI/CD:   ssl:ci.perforce.yourdomain.com:1666

Use Cases Enabled:

  • Disaster Recovery: Promote standby replica during primary maintenance
  • CI/CD Offloading: Point build systems to readonly replicas
  • Performance Scaling: Distribute read load across multiple servers
  • Zero Downtime Maintenance: Failover to replica during updates

Cross-Region Support: Infrastructure supports both same-region and cross-region replica deployments with provider aliases and networking validation

Checklist

If your change doesn't seem to apply, please leave them unchecked.

  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented
Is this a breaking change?

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created might not be successful.

@novekm novekm requested a review from a team as a code owner August 28, 2025 11:34
@novekm novekm requested a review from erikyb August 28, 2025 11:34
@novekm novekm changed the title initial commit feat: replication for p4 server Aug 28, 2025
@novekm novekm marked this pull request as draft August 28, 2025 11:34
@novekm novekm self-assigned this Aug 28, 2025
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checkov found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@novekm novekm added enhancement New feature or request feature-request feature request perforce terraform Pull requests that update Terraform code labels Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature-request feature request perforce terraform Pull requests that update Terraform code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant